package com.itistimetothink.cjetso.graphics;

import com.itistimetothink.cjetso.utilities.Marker;
import com.itistimetothink.cjetso.utilities.Utilities;

import android.graphics.Bitmap;
import android.graphics.Canvas;

public class IconMarker extends Marker {
    private Bitmap bitmap = null;

    public IconMarker(String name, String address, String phone, String description,
			double latitude, double longitude, String type, String category, 
			int has_coupon, String coupon, String coupon_pic, String due_date, String pic_1, String pic_2, String pic_3,
			String like_count, String dislike_count, String not_here,
			int color, Bitmap bitmap)
    {
        super(name, address, phone, description, 
				latitude, longitude, type, category, 
				has_coupon, coupon, coupon_pic, due_date, pic_1, pic_2, pic_3, like_count, dislike_count, not_here, 
				color);
        this.bitmap = bitmap;
    }

    @Override
    public void drawIcon(Canvas canvas) {
    	if (canvas==null || bitmap==null) throw new NullPointerException();

        if (gpsSymbol==null) gpsSymbol = new PaintableIcon(bitmap,96,96);

        textXyzRelativeToCameraView.get(textArray);
        symbolXyzRelativeToCameraView.get(symbolArray);

        float currentAngle = Utilities.getAngle(symbolArray[0], symbolArray[1], textArray[0], textArray[1]);
        float angle = currentAngle + 90;

        if (symbolContainer==null) symbolContainer = new PaintablePosition(gpsSymbol, symbolArray[0], symbolArray[1], angle, 1);
        else symbolContainer.set(gpsSymbol, symbolArray[0], symbolArray[1], angle, 1);

        symbolContainer.paint(canvas);
    }
}